//
//  GXSearchResultDetailViewController.m
//  GXLanOuADemo
//
//  Created by 甘霞 on 15/11/6.
//  Copyright © 2015年 甘霞. All rights reserved.
//

#import "GXSearchResultDetailViewController.h"
#import "GXSuggestModel.h"

@interface GXSearchResultDetailViewController () <UIWebViewDelegate, UIScrollViewDelegate>

@end

@implementation GXSearchResultDetailViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view setBackgroundColor:[UIColor whiteColor]];
    self.navigationController.navigationBarHidden = YES;
    
    [self createWebViewWithFrame:CGRectMake(0, 20, kScreenWidth, kScreenHeight - 20) URL:[NSURL URLWithString:self.suggestModel.item_url]];
    self.webView.delegate = self;
    self.webView.scrollView.delegate = self;
    self.webView.scrollView.bounces = NO;
    [self createButtomLikeButton];
    [self.backBtn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.repostBtn setHidden:YES];
    [self.likeBtn setHidden:YES];
}

- (void)buttonAction:(UIButton *)btn {
    self.navigationController.navigationBarHidden = NO;
    [self.navigationController popToRootViewControllerAnimated:YES];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"navi" object:nil];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    static CGFloat y;
    if (scrollView.contentOffset.y > y) {
        [UIView animateWithDuration:1 animations:^{
            self.backBtn.alpha = 0;
            self.repostBtn.alpha = 0;
            self.likeBtn.alpha = 0;
        }];
        y = scrollView.contentOffset.y;
    }
    if (scrollView.contentOffset.y < y) {
        [UIView animateWithDuration:1 animations:^{
            self.backBtn.alpha = 0.8;
            self.repostBtn.alpha = 0.8;
            self.likeBtn.alpha = 0.8;
        }];
        y = scrollView.contentOffset.y;
    }
}

- (void)viewWillDisappear:(BOOL)animated
{
//    [self.navigationItem.titleView reloadInputViews];
    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden = NO;
    NSLog(@"~~~%@", self.navigationItem.titleView);
}

@end
